
data <- read.csv("trust_ssa.csv", stringsAsFactors = FALSE)

# View the first few rows
head(data)

# Check the structure of the data
str(data)

library(tidyr)
data_long <- pivot_longer(data, cols = c(scot_gov, uk_gov), names_to = "government", values_to = "trust")

library(ggplot2)

ggplot(data_long, aes(x = year, y = trust, color = government)) +
  geom_line(size = 1.5, alpha = 0.5) +
  geom_point() +
  scale_color_manual(values = c("scot_gov" = "#506dd5", "uk_gov" = "#d55070"),
                     labels = c("Scottish Government", "UK Government")) +
  labs(title = "Trust the Scottish/UK Government to make fair decisions 'a great deal' or 'quite a lot'",
       x = "Year",
       y = "% Agree",
       color = "Government") +
  theme_minimal() +
  ylim(10, 50) +
  theme(legend.position = "bottom")